﻿using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using System.Runtime.Serialization;
using System.Windows.Forms;
using OpenComposite.Workflow.Properties;

namespace OpenComposite.Workflow
{
	[Designer(typeof(HumanCapabilityDesigner))]
	[ToolboxItem(typeof(HumanCapabilityToolboxItem))]
	[ToolboxBitmap(typeof(resfinder), "OpenComposite.Workflow.Resources.user_green.png")]
	public class HumanCapabilityActivity : LogicalCapabilityActivity
	{
		public HumanCapabilityActivity()
		{
		}
	}

	[ActivityDesignerTheme(typeof(HumanCapabilityDesignerTheme))]
	public class HumanCapabilityDesigner : LogicalCapabilityActivityDesigner
	{
		protected override void OnPaint(ActivityDesignerPaintEventArgs e)
		{
			if ( !IsVisible )
				return;

			base.OnPaint(e);
		}

		protected override void OnMouseUp(MouseEventArgs e)
		{
			if ( e.Button == MouseButtons.Left && e.Clicks == 1 ) {
				// create composite
			}
			base.OnMouseUp(e);
		}

		protected override Rectangle ImageRectangle
		{
			get
			{
				Rectangle rc = base.ImageRectangle;
				rc.Offset(3, 0);
				return rc;
			}
		}
	}

	[Serializable]
	public class HumanCapabilityToolboxItem : ActivityToolboxItem
	{
		public HumanCapabilityToolboxItem(Type type)
			: base(type)
		{
			this.DisplayName = "Capability (Human Activity)";
		}

		private HumanCapabilityToolboxItem(SerializationInfo info, StreamingContext context)
		{
			Deserialize(info, context);
		}
	}

	public class HumanCapabilityDesignerTheme : LogicalCapabilityActivityDesignerTheme
	{
		public HumanCapabilityDesignerTheme(WorkflowTheme theme)
			: base(theme)
		{
		}
	}
}
